﻿using System;

namespace Iot.RealTimeData;

public sealed class RealTimeDataInfo
{
    private static readonly TimeSpan StaticPeriod = TimeSpan.FromSeconds(5);

    private readonly object _lock = new();

    private bool _isEnable;

    private TimeSpan _period = StaticPeriod;

    private int _staleBated = 5;

    /// <summary>
    ///     是否启动过期删除功能
    /// </summary>
    public bool IsEnable
    {
        get
        {
            lock (_lock)
            {
                return _isEnable;
            }
        }
        set
        {
            lock (_lock)
            {
                _isEnable = value;
            }
        }
    }

    /// <summary>
    ///     模拟量过期时间    秒
    /// </summary>
    public int StaleBated
    {
        get
        {
            lock (_lock)
            {
                return _staleBated;
            }
        }
        set
        {
            lock (_lock)
            {
                _staleBated = value;
            }
        }
    }

    /// <summary>
    ///     扫描周期   秒
    /// </summary>
    public TimeSpan Period
    {
        get
        {
            lock (_lock)
            {
                return _period;
            }
        }
        set
        {
            lock (_lock)
            {
                _period = value;
            }
        }
    }
}